<?php
	$title='Manage Site';
	$description='manage';
	$keywords='manage';
?>
<?php include('fns_db_manage_pics.php'); ?>
<?php include('../views/layouts/_header.php'); ?>
<?php include('../views/layouts/_left.php'); ?>
<?php
if(!checkIfAdmin()){
	header("location: ../index.php");
}
?>

<?php
function showAllPics(){
	$result = get_all_pics_ordered_by_date();

	echo 'All pics ('.mysqli_num_rows($result).'):<br/><br/>';

	$myrow = mysqli_fetch_assoc ($result);
	do {
		printf ("<img src='../photos/photos/medium/%s.jpg'> <br/><a href='manage_pics.php?action=del&id=%s'>delete</a><hr/>", $myrow["id"], $myrow["id"]);
	}while ($myrow = mysqli_fetch_assoc ($result));
}

if(isset($_GET['action']) && $_GET['action'] == "del"){
	delete_pic($_GET['id']);
	showAllPics();
}else{
	showAllPics();
}
?>




<?php include('../views/layouts/_footer.php'); ?>